#include <unistd.h>
#include "../app/app_mqtt.h"
#include "../app/app_pool.h"
#include "../app/app_device.h"
#include "../thirdparty/log.h"
#include "../app/app_bt.h"
#include "../app/app_serial.h"

int main(void)
{
    app_dev_t *dev = App_device_Init();
    if (dev == NULL)
    {
        log_error("device init fail\n");
        return -1;
    }
    App_mqtt_Init();
    int res = App_pool_Init();
    if (res == -1)
    {
        log_error("pool init fail\n");
        return -1;
    }
    res = App_serial_Init(dev);
    if (res == -1)
    {
        log_error("serial init fail\n");
        return -1;
    }
    res = App_bt_Init(dev);
    if (res == -1)
    {
        log_error("bt init fail\n");
        return -1;
    }
    App_device_Start(dev);
    while (1)
    {
        sleep(1);
    }

    return 0;
}